//
//  Dispatch_queueDemo.m
//  JKThreadTest
//
//  Created by 王冲 on 2018/10/25.
//  Copyright © 2018年 JK科技有限公司. All rights reserved.
//

#import "Dispatch_queueDemo.h"

@interface Dispatch_queueDemo ()

@property(nonatomic,strong) dispatch_queue_t ticketLock;
@property(nonatomic,strong) dispatch_queue_t moneyLock;

@end

@implementation Dispatch_queueDemo

-(instancetype)init{
    
    if (self = [super init]) {
        
        // 初始化锁
        self.ticketLock = dispatch_queue_create("ticketLock", DISPATCH_QUEUE_SERIAL);
        
        self.moneyLock = dispatch_queue_create("moneyLock", DISPATCH_QUEUE_SERIAL);
    }
    
    return self;
}

-(void)__buyTicket{
    
    dispatch_sync(self.ticketLock, ^{
        
        [super __buyTicket];
    });

}

-(void)__drawMoney{
    
    dispatch_sync(self.ticketLock, ^{
        
        [super __drawMoney];
    });

}

-(void)__saveMoney{
    
    dispatch_sync(self.ticketLock, ^{
        
        [super __saveMoney];
    });
}

@end
